<template>
  <div class='login'>
    <div class='icon'>
      <img src="../assets/img/icon.png" alt="">
    </div>
    <!-- <form action="" ref="user"> -->
      <div class='username'>
      <label for="">用户名：</label>
    <input type="text" v-model="user.account">
    </div>
    <div class='psd'>
      <label for="">密&nbsp;&nbsp;&nbsp;码：</label>
     <input type="password" v-model="user.password">
    </div>
    <div class='loginBtn'>
      <input type="button" value="登录" @click="loginBtn">登 录
      <a class="forget">忘记密码？</a>
    </div>
    <!-- </form> -->
  </div>
</template>

<script>
import { checkUser } from "../api/index.js";
import { MessageBox } from "mint-ui";
export default {
  data() {
    return {
      user: {
        account: "",
        password: ""
      }
    };
  },
  methods: {
    loginBtn() {
      if (this.user.account != "" && this.user.password != "") {
        checkUser({ params: this.user }).then(res => {
          console.log(res);
          if (res.code == 1) {
            this.$store.commit("userid", res.data.userid);
            this.$router.push("/");
          } else {
            MessageBox.alert(res.msg);
          }
        });
      }
    }
  }
};
</script>

<style >
.login {
  background: url(../assets/img/bg.png);
  background-size: cover;
  background-position: center;
  height: 100%;
  width: 100%;
  font-size: 20px;
}
.icon {
  text-align: center;
  margin-bottom: 1.2rem;
}
.icon img {
  width: 1.09rem;
  margin-top: 55px;
}
.username,
.psd {
  position: relative;
  line-height: 0.5rem;
  color: #fff;
  background: url(../assets/img/input.png);
  background-size: cover;
  background-position: center;
  height: 0.5rem;
  width: 86%;
  margin: auto;
}
.psd {
  border-top: 1px solid #fff;
  border-radius: 0 0 6px 6px;
}
.username {
  border-radius: 6px 6px 0 0;
}
.username input,
.psd input {
  position: absolute;
  background: none;
  border: none;
  width: 2rem;
  height: 0.6rem;
  line-height: 60px;
  left: 130px;
  top: 0;
  outline: medium;
  font-size: 20px;
}
.username label,
.psd label {
  position: absolute;
  left: 20px;
  top: -20px;
  margin: 25px;
}
.loginBtn {
  position: relative;
  line-height: 40px;
  color: #fff;
  background: url(../assets/img/login.png);
  background-size: cover;
  background-position: center;
  height: 40px;
  width: 86%;
  margin: auto;
  border-radius: 6px;
  text-align: center;
  margin-top: 50px;
}
.loginBtn input {
  position: absolute;
  border: none;
  width: 100%;
  height: 50px;
  right: 0px;
  top: 0;
  outline: medium;
  opacity: 0;
}
.forget {
  position: absolute;
  right: 0px;
  top: 40px;
}

.test {
  width: 1rem;
  height: 1rem;

  background-color: red;
}

body {
  font-size: 12px;
}
</style>


